package com.hdax.easybuy.controller;

import com.hdax.easybuy.dao.ProductCategoryDao;
import com.hdax.easybuy.dao.ProductDao;
import com.hdax.easybuy.entity.Product;
import com.hdax.easybuy.entity.ProductCategory;
import com.hdax.easybuy.entity.Users;
import com.hdax.easybuy.service.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping(value = "/providerProduct")
public class ProductProviderController {
    @Resource
    private ProductDao productDao;

    @Resource
    private ProductService productService;
    //查看所有的商品
    @RequestMapping("/queryAllProduct")
    @ResponseBody
    public List<Product> queryAll(){
        return productDao.findAll();
    }
    //根据id查看单个商品
    @RequestMapping("/queryById/{id}")
    @ResponseBody
    public Product queryById(@PathVariable("id") int id){
        return productDao.findOne(id);
    }
    //一级菜单下面所有的商品
    @RequestMapping("/queryProductById/{id}")
    public List<Product> queryProductById(@PathVariable("id") int id){
        return productDao.findByCategoryLevel1Id(id);
    }


}
